package service;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.util.Properties;

public class Factory {

	private static Factory instance = null;

	private static Properties prop;

	private Factory() {
		prop = new Properties();
		try {
			prop.load(new FileInputStream("Config.properties"));
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public static Factory getInstance() {
		if (instance == null)
			instance = new Factory();
		return instance;
	}

	public Registry getRegistry() throws RemoteException {
		return LocateRegistry.getRegistry(prop.getProperty("host"),
				Integer.valueOf(prop.getProperty("port")));
	}

	public String getArticle() {
		return prop.getProperty("article");
	}

	public String getClient() {
		return prop.getProperty("client");
	}

	public String getEmployee() {
		return prop.getProperty("employee");
	}

	public String getSale() {
		return prop.getProperty("sale");
	}

}
